<template>
    <van-nav-bar title="优惠券" left-text="" left-arrow @click-left="goBack" />
    <div class="coupon_list">
        <div class="coupon_item" v-for="item in couponlist" :key="item.id">
            <div class="item_content">
                <router-link :to="{path: '/coupon/info', query:{cid: item.id}}">
                    <div class="left">
                        {{ item.rate * 100 }}<span>折</span>
                    </div>
                    <div class="right">
                        <div>{{ item.title }}</div>
                        <div>活动开始：{{ item.createtime_text }}</div>
                        <div>活动结束：{{ item.endtime_text }}</div>
                        <div>领取数量：{{ item.total }}张，每人限领1张</div>
                    </div>
                </router-link>
            </div>
            <div class="item_btn">
                <router-link :to="{path: '/coupon/info', query:{cid: item.id}}" class="right_btn">
                    优惠详情
                </router-link>
            </div>
        </div>
    </div>
    <div class="more">没有更多了</div>
</template>
<script setup>
const { proxy } = getCurrentInstance()
const goBack = () => {
    proxy.$router.go(-1)
}
let couponlist = ref([])
onBeforeMount(() => {
    getCouponData()
})
const getCouponData = async () => {
    let result = await Api.CouponIndex()
    if (result.code == 1) {
        couponlist.value = result.data
    }
}
</script>
<style>
@import url('/assets/css/coupon.css');
</style>